﻿@using Apps.Web.Core;
@using Apps.Web;
@using Apps.Common;
@using Apps.Models.Sys;
@using Apps.Locale;
@using Apps.Web.Core;
@using Apps.Web;
@using Apps.Common;
@using Apps.Models.Sys;
@using Apps.Locale;
@using Wantn.FIS.Enum
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index_Layout.cshtml";
    List<permModel> perm = null;
    //岩相管理
}

<div id="uploadExcel" class="easyui-window" data-options="modal:true,closed:true,minimizable:false,shadow:false">
    <form name="form1" method="post" id="form1">
        <table>
            <tr>
                <th style="padding:20px; "> Excel：</th>
                <td style="padding:20px; ">
                    <input name="ExcelPath" type="text" maxlength="255" id="txtExcelPath" readonly="readonly" style="width:200px" class="txtInput normal left">
                    <a href="javascript:$('#FileUpload').trigger('click').void(0);" class="files">@Resource.Browse</a>
                    <input class="displaynone" type="file" id="FileUpload" name="FileUpload" onchange="Upload('ExcelFile', 'txtExcelPath', 'FileUpload'); ">
                    <span class="uploading">@Resource.Uploading</span>
                </td>
            </tr>
        </table>
        <div class="endbtndiv">
            <a id="btnSave" href="javascript:ImportData()" class="easyui-linkbutton btns">直接保存</a>
            <a id="btnReturn" href="javascript:$('#uploadExcel').window('close')" class="easyui-linkbutton btnc">@Resource.Cancel</a>
        </div>
    </form>
</div>
<div class="mvctool">
    <input id="txtBatchCode" type="text" class="searchText" placeholder="批次编码" />
    <input id="txtStartDate" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd', maxDate: '#F{$dp.$D(\'txtEndDate\')}' })" class="condition-date" type="text" placeholder="日期起" />
    <input id="txtEndDate" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd', minDate: '#F{$dp.$D(\'txtStartDate\')}' })" class="condition-date" type="text" placeholder="日期止" />
    <select class="easyui-combobox" name="BATCH_TYPE" id="BATCH_TYPE" style="width:120px;">
        <option value="">=== 全部类别 ===</option>
        <option value="入厂煤">入厂煤</option>
        <option value="自采煤">其他</option>
    </select>
    <select class="easyui-combobox" name="TYPE_ID" id="TYPE_ID" style="width:120px;"></select>
    <select class="easyui-combobox" name="MATERIEL_ID" id="MATERIEL_ID" style="width:120px;"></select>
    <select class="easyui-combobox" name="isJsuan" id="isJsuan" style="width:120px;">
        <option value="">===结算状态===</option>
        <option value="是">是</option>
        <option value="否">否</option>
    </select>
    <select class="easyui-combobox" name="jsRelated" id="jsRelated" style="width:120px;">

        <option value="">===关联状态===</option>
        <option value="是">是</option>
        <option value="否">否</option>
    </select>
    @Html.ToolButton("btnQuery", "fa fa-search", Resource.Query, ref perm, "Query", true)
    @Html.ToolButton("btnExprot", "fa fa-download", Resource.Export, ref perm, "Export", true)
</div>
<table id="List"></table>
@Html.Partial("~/Views/Shared/_Partial_AutoGrid.cshtml")

<div id="modalwindow" class="easyui-window" style="width:800px; height:400px;" data-options="modal:true,closed:true,minimizable:false,shadow:false"></div>
<script type="text/javascript">


    $(function () {

        $.ajax({
            url: '../../RC/SAMPLING/GetTranSuppList?type=4',
            type: 'post',
            dataType: 'json',
            success: function (result) {
                $('#TYPE_ID').combobox({
                    data: result,
                    valueField: 'Value',
                    textField: 'Text',
                    onLoadSuccess: function () {

                    }
                });
            },
        });

         GetTranSuppList(2, "@ViewBag.MATERIEL_ID");
        $('#List').datagrid({
            url: '@Url.Action("GetList")',
            width: SetGridWidthSub(10),
            methord: 'post',
            height: SetGridHeightSub(45),
            fitColumns: true,
            sortName: 'ADDTIME',
            sortOrder: 'desc',
            idField: 'ID',
            pageSize: 15,
            pageList: [15, 20, 30, 40, 50],
            pagination: true,
            striped: true, //奇偶行是否区分
            singleSelect: true,//单选模式
            selectOnCheck: false,
            checkOnSelect: false,
            checkbox: true,
            rownumbers: true,//行号
            onLoadSuccess: function (data) {
                $("#List").datagrid("clearSelections"); //全部不选中
                $("#List").datagrid("clearChecked"); //全部不选中
                $("#List").datagrid("unselectAll"); //全部不选中
            },
            columns: [[
                { field: 'STR_MATCH_TIME', title: '入厂日期', width: 100, sortable: true },
                { field: 'STR_COLLECT_TIME', title: '收样时间', width: 140 },
                { field: 'BATCH_TYPE', title: '批次类型', width: '80px' },
                { field: 'BATCH_CODE', title: '批次码', width: '100px' },
                { field: 'MATERIEL_NAME', title: '物料', width: 140 },
                { field: 'TYPE_STR', title: '类型', width: 100 },
                { field: 'CRI', title: 'CRI%', width: 80 },
                { field: 'CSR', title: 'CSR%', width:80 },
                { field: 'YANX_VALUE', title: '岩相', width: 80 },
                { field: 'MT', title: 'Mt(%)', width: 80 },
                { field: 'MAD', title: 'Mad(%)', width: 80 },
                { field: 'AD', title: 'Ad(%)', width: 80 },
                { field: 'VDAF', title: 'Vdaf(%)', width: 80 },
                { field: 'STD', title: 'St,d(%)', width: 80 },
                { field: 'G', title: 'G(%)', width: 80 },
                { field: 'Y', title: 'Y(%)', width: 80 },
                { field: 'X', title: 'X(%)', width: 80 },
                { field: 'A', title: 'a(%)', width: 80 },
                { field: 'B', title: 'b(%)', width: 80 },
                { field: 'QNETAR_KCAL', title: 'Qnet,ar（kcal/kg)', width: 120 },
                { field: 'SMALL', title: '<3mm(%)', width: 80 },
                { field: 'SMEDIUN', title: '<0.5mm(%)', width: 80 },
                { field: 'MEDIUM', title: '3~10mm(%)', width: 80 },
                { field: 'LARGE', title: '>10mm(%)', width: 80 },
                { field: 'M40', title: 'M40(%)', width: 80 },
                { field: 'M10', title: 'M10(%)', width: 80 },
                { field: 'JTXXLARGE', title: '>80mm(%)', width: 80 },
                { field: 'JTXLARGE', title: '80~60mm%)', width: 80 },
                { field: 'JTLARGE', title: '60~40mm%)', width: 80 },
                { field: 'JTMEDIUM', title: '40~25mm(%)', width: 80 },
                { field: 'JTSMALL', title: '<25mm(%)', width: 80 },
            ]], onClickRow: function (index, row) {
            }
        });
    });

    function cellStyler(value, row, index) {
        if (value == '是') {
            return 'color:#FF5722; text-align:center';
        }
        if (value != '' && value != undefined) {
            return 'color:#FF5722; text-align:center';
        }
    }
    //ifram 返回
    function frameReturnByClose() {
        $("#modalwindow").window('close');
    }

    function frameReturnByReload(flag) {
        if (flag)
            $("#List").datagrid('load');
        else
            $("#List").datagrid('reload');
        $("#List").datagrid("clearSelections"); //全部不选中
        $("#List").datagrid("clearChecked"); //全部不选中
        $("#List").datagrid("unselectAll"); //全部不选中
    }
    function frameReturnByMes(mes) {
        $.messageBox5s(Lang.Tip, mes);
    }
    function GetData() {
        $("#List").datagrid("load", {
            BatchType: $("#BATCH_TYPE").combobox('getValues').toString(),
            startdate: $("#txtStartDate").val(),
            enddate: $("#txtEndDate").val(),
            isJsuan: $("#isJsuan").combobox('getText').toString(),
            jsRelated: $("#jsRelated").combobox('getText').toString(),
            materielName: $("#MATERIEL_ID").combobox('getText').toString(),
            TypeStr: $("#TYPE_ID").combobox('getValues').toString(),
            batchCode: $("#txtBatchCode").val(),
        });
    }
    $(function () {
        $("#btnQuery").click(function () {
            GetData();
        });
        $("#btnExprot").click(function () {
            let startdate = $("#txtStartDate").val();
            let enddate = $("#txtEndDate").val();
            let materielName = $("#MATERIEL_ID").combobox('getText').toString();
            let batchType = $("#BATCH_TYPE").combobox('getValues').toString();
            let isJsuan = $("#isJsuan").combobox('getText').toString();
            let jsRelated = $("#jsRelated").combobox('getText').toString();

            let TypeStr = $("#TYPE_ID").combobox('getValues').toString();
            let batchCode = $("#txtBatchCode").val();

            if (startdate == '' || startdate == undefined) {
                $.messageBox5s(Lang.Tip, '请选择开始日期');
                return;
            }
            if (enddate == '' || enddate == undefined) {
                $.messageBox5s(Lang.Tip, '请选择结束日期');
                return;
            }
            GetData();
            var url = '@Url.Action("Export")' + '?materielName=' + materielName + '&startdate=' + startdate + '&enddate=' + enddate + '&batchType=' + batchType + '&isJsuan=' + isJsuan + '&jsRelated=' + jsRelated + '&TypeStr=' + TypeStr + '&batchCode=' + batchCode;
            window.open(url);
         });
    });
</script>

